package itheima.com.Demo01.Tesk.Tesk01;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Test01 {
    public static void main(String[] args) {
        Map<Studnet,String> map = new HashMap<>();
        Studnet s1 = new Studnet("aaa",21);
        Studnet s2 = new Studnet("bbb",22);
        Studnet s3 = new Studnet("ccc",24);
        map.put(s1,"湖南");
        map.put(s2,"北京");
        map.put(s3,"天津");





        Set<Studnet> studnets = map.keySet();
        for (Studnet studnet : studnets) {
            String s = map.get(studnet);
            System.out.println(studnet+"---"+s);
        }

        Iterator<Studnet> iterator = studnets.iterator();
        while (iterator.hasNext()){
            Studnet next = iterator.next();
            System.out.println(next+"---"+map.get(next));

        }


        Set<Map.Entry<Studnet, String>> entries = map.entrySet();
        for (Map.Entry<Studnet, String> entry : entries) {
            System.out.println(entry.getKey()+"----"+entry.getValue());
        }

        map.forEach(
                (Studnet s,String ss)->{
                    System.out.println(s+"---"+ss);
                }
        );
    }
}
